<template>
  <div class="login-form login-signin">
    <div class="pb-13 pt-lg-0 pt-5">
      <h3 class="font-weight-bolder text-dark font-size-h4 font-size-h1-lg">
        请在邮箱中查看您的激活码
      </h3>
    </div>
    <div class="form-group">
      <div id="example-input-group-2" label="" label-for="example-input-2">
        <input
          class="form-control form-control-solid h-auto py-7 px-6 rounded-lg"
          type="text"
          name="password"
          placeholder="激活码"
          ref="password"
          v-model="activeCode"
          autocomplete="off"
        />
      </div>
    </div>
    <div class="pb-lg-0 pb-5">
      <button
        class="btn btn-primary font-weight-bolder font-size-h6 px-15 py-4 my-3 mr-3"
        @click="myActive()"
      >
        激 活
      </button>
      <button
        class="btn btn-success font-weight-bolder font-size-h6 px-15 py-4 my-3 mr-3"
        style="background-color: grue"
        @click="openRegister()"
      >
        返 回
      </button>
    </div>
  </div>
</template>
<script>
export default {
  name: "LoginForm",
  data() {
    return {
      activeCode: "",
    };
  },
  created() {},
  methods: {
    myActive() {
      this.$axios({
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: "/api/user/activeUser", //后端请求的路径
        method: "post",
        params: {
          email: sessionStorage.getItem("email"),
          activeCode: this.activeCode,
        },
      }).then((response) => {
        if (response.status == 0) {
          sessionStorage.setItem("token", response.token);
          sessionStorage.setItem("firstLogin", true);
          this.$notify({
            title: "激活成功",
            message: "欢迎登录乐游实战开发平台",
          });
          this.$router.push("/dashboard");
        }
      });
    },
    openRegister() {
      this.$parent.openRegisterForm();
    },
  },
};
</script>
